package com.acme.javaschool.sems.ionio.serialization.impl;

import com.acme.javaschool.sems.ionio.serialization.SensorData;
import com.acme.javaschool.sems.ionio.serialization.Serializer;
import com.thoughtworks.xstream.XStream;

import java.io.InputStream;
import java.io.OutputStream;


public class XmlSerializer implements Serializer<SensorData>{
    private final XStream xstream = new XStream();

    @Override
    public void serialize(OutputStream outputStream, SensorData object) {
        xstream.toXML(object, outputStream);
    }

    @Override
    public SensorData deserialize(InputStream inputStream) {
        return (SensorData) xstream.fromXML(inputStream);
    }
}
